<?php
/**
 * js语法分析器
 */
class Interpreter {
    
    /**
     * 用于缓存js代码的字符流
     * @var string
     */
    private $stream;
    
    /**
     * 用于缓存js代码的token列表
     * @var array
     */
    private $tokenList;
    
    /**
     * 用于缓存grammar tree
     * @var array
     */
    private $grammarTree;
    
    public function __construct($stream) {
        $this->stream = $stream;
        $this->tokenList = array();
        $this->grammarTree = array();
    }
    
    public function run(){
        
        // 词法分析
        $lexicalAnalyzer = new LexicalAnalyzer($this->stream);
        $this->tokenList = $lexicalAnalyzer->run();
        
        print_r($this->tokenList);
        /*
        // 语法分析
        $grammarAnalyzer = new GrammarAnalyzer($this->tokenList);
        $this->grammarTree = $grammarAnalyzer->run();
        
        print_r($this->grammarTree);
        */
    }
}